package com.sugar.psych.assessment.module.business.dal.mysql.user;


import com.sugar.psych.assessment.framework.common.pojo.PageResult;
import com.sugar.psych.assessment.framework.mybatis.core.mapper.BaseMapperX;
import com.sugar.psych.assessment.framework.mybatis.core.query.MPJLambdaWrapperX;
import com.sugar.psych.assessment.module.business.dal.dataobject.user.UserDO;
import org.apache.ibatis.annotations.Mapper;
import com.sugar.psych.assessment.module.business.controller.admin.user.vo.*;

/**
 * 用户信息 Mapper
 *
 * @author Ysugar
 */
@Mapper
public interface BizUserMapper extends BaseMapperX<UserDO> {

    default PageResult<UserRespVO> selectPage(UserPageReqVO reqVO) {
        return selectJoinPage(reqVO, UserRespVO.class, new MPJLambdaWrapperX<UserDO>()
                .selectAll(UserDO.class)
                .likeIfPresent(UserDO::getUsername, reqVO.getUsername())
                .likeIfPresent(UserDO::getNickname, reqVO.getNickname())
                .eqIfPresent(UserDO::getMobile, reqVO.getMobile())
                .eqIfPresent(UserDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(UserDO::getLastLoginTime, reqVO.getLastLoginTime())
                .betweenIfPresent(UserDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(UserDO::getId));
    }

}